<template>
	<div>
		<el-select class="w-ipt" v-model="c_search_name" remote filterable value-key="uuid" :remote-method="changeUuid"
			placeholder="请搜索uuid添加" @change="handleCheckUuid" :disabled="c_ban_edit">
			<el-option v-for="item in uuid_list" :key="item.id" :label="item.uuid" :value="item.uuid">
			</el-option>
		</el-select>
	</div>
</template>

<script>
	import API from '@/api/index.js'

	export default {
		data() {
			return {
				uuid_list: [],
				c_search_name: this.uuid,
				c_ban_edit: this.ban_edit
			}
		},
		props: ['uuid', 'ban_edit'],
		watch: {
			uuid(val) {
				this.c_search_name = val;
			},
			ban_edit(val) {
				this.c_ban_edit = val;
			}
		},
		methods: {
			// 加载更多数据
			changeUuid(val) {
				let self = this;
				self.c_search_name = val;
				API.unknownDevice(self.c_search_name).then(res => {
					let data = res.data.data;
					self.uuid_list = data.data;
					console.log(self.uuid_list)
				}).catch(err => {
					self.$message.error(err.response.data.message)
				});
			},
			// 选择了uuid
			handleCheckUuid(val) {
				let self = this;
				console.log(val)
				self.$emit('getUuid', {
					uuid: val
				})
			}
		}
	}
</script>

<style scoped lang="scss">
</style>
